package mi.payment.ui.admin;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import mi.payment.R;
import mi.payment.controller.BaseQpsSettingController;
import mi.payment.controller.QpsSettingController;
import mi.payment.ui.base.ParentActivity;
import sunmi.sunmiui.title.Title;

/**
 * 交易管理设置
 * Created by hehj on 2017/2/13.
 */
public class TransactionManageSettingsActivity extends ParentActivity {
    private View mTransactionSwitchSetting, mTransactionEncryptionSetting, mSettlementTransactionSetting, mOfflineTransactionSetting, mOtherTransactionSetting, mQpsSetting;
    private BaseQpsSettingController controller;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transaction_manage_settings);
        controller = new QpsSettingController(this);
        initView();
        setClickListener();
    }

    /**
     * 初始化控件
     */
    private void initView() {
        Title mTitle;
        TextView mLeftText;
        mTitle = (Title) findViewById(R.id.transaction_manage_setting_title);
        mTitle.setButtonVisibility(false, true, true, true);
        mTitle.setHeadBgColor(getResources().getColor(R.color.colorBar));
        mTitle.setTitleText(getResources().getString(R.string.transaction_management_settings));
        mTitle.setMenuClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TransactionManageSettingsActivity.this.finish();
            }
        }, null, null, null);

        mTransactionSwitchSetting = findViewById(R.id.transaction_switch_setting);
        mTransactionEncryptionSetting = findViewById(R.id.transaction_encryption_setting);
        mSettlementTransactionSetting = findViewById(R.id.settlement_transaction_setting);
        mOfflineTransactionSetting = findViewById(R.id.off_line_transaction_setting);
        mOtherTransactionSetting = findViewById(R.id.other_transaction_setting);
        mQpsSetting = findViewById(R.id.qps_setting);
        if (!controller.show()) {
            mQpsSetting.setVisibility(View.GONE);
        }

        mLeftText = (TextView) mTransactionSwitchSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.transaction_switch_setting));

        mLeftText = (TextView) mTransactionEncryptionSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.transaction_encryption_setting));

        mLeftText = (TextView) mSettlementTransactionSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.settlement_transaction_setting));

        mLeftText = (TextView) mOfflineTransactionSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.off_line_transaction_setting));

        mLeftText = (TextView) mOtherTransactionSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.other_transaction_setting));

        mLeftText = (TextView) mQpsSetting.findViewById(R.id.item_left_text);
        mLeftText.setText(getResources().getString(R.string.qps_setting));


    }

    /**
     * 设置点击事件
     */
    private void setClickListener() {
        mTransactionSwitchSetting.setOnClickListener(this);
        mTransactionEncryptionSetting.setOnClickListener(this);
        mSettlementTransactionSetting.setOnClickListener(this);
        mOfflineTransactionSetting.setOnClickListener(this);
        mOtherTransactionSetting.setOnClickListener(this);
        mQpsSetting.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.transaction_switch_setting:
                //交易开关控制
                startActivity(new Intent(this, TransactionSwitchSettingsActivity.class));
                break;
            case R.id.transaction_encryption_setting:
                //交易输密控制
                startActivity(new Intent(this, TransactionEncryptionSettingActivity.class));
                break;
            case R.id.settlement_transaction_setting:
                //结算交易控制
                startActivity(new Intent(this, SettlementTransactionSettingsActivity.class));
                break;
            case R.id.off_line_transaction_setting:
                //离线交易控制
                startActivity(new Intent(this, OfflineTransactionSettingActivity.class));
                break;
            case R.id.other_transaction_setting:
                //其它交易控制
                startActivity(new Intent(this, OtherTransactionSettingActivity.class));
                break;
            case R.id.qps_setting:
                //非接业务参数控制
                startActivity(new Intent(this, QpsTransactionSettingActivity.class));
                break;
            default:
                break;

        }
    }
}
